package com.itheima.lisenter;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class LisentMss {
    @RabbitListener(queues = "hello")
    public void consumerMes(Map map){
        System.out.println("接受到消息==>"+map);

    }
    /**
     * 监听: topic_queue 队列
     * 交换器:  spring_topic_ex  主题交换器
     * 绑定:  route_key:  #.key.#
     * 注解绑定交换机
     */
    @RabbitListener( bindings ={
            @QueueBinding(
                    //声明队列
                    value =@Queue(value ="topic_queue" ,durable = "true"),
                    //设置交换机
                    exchange = @Exchange(value = "spring_topic_ex",type ="topic" ),
                    //路由绑定(队列和交换机)
                    key = "#.key.#"
            )
    })
    public void consumerMes2(Map map){
        System.out.println("topic_queue接受到消息==>"+map);

    }


}
